package com.eshopkeeper.provider.sys;

import com.baomidou.mybatisplus.plugins.Page;
import com.eshopkeeper.core.base.BaseProviderImpl;
import com.eshopkeeper.dao.sys.StatsDataMapper;
import com.eshopkeeper.model.sys.StatsData;
import com.weibo.api.motan.config.springsupport.annotation.MotanService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Map;

/**
 * Created by louis on 17-4-7.
 */

//@CacheConfig(cacheNames = "statsData")
@MotanService(basicService = "serviceBasicConfig")
public class StatsDataProviderImpl extends BaseProviderImpl<StatsData> implements IStatsDataProvider {

	@Autowired
	private StatsDataMapper statsDataMapper;

	@Override
	public Page<StatsData> getStatsDataPageList(Map<String, Object> params) {
		Page<Long> idPage = this.getPage(params);
		idPage.setRecords(statsDataMapper.selectIdByMap(idPage, params));
		return getPageNotFromRedis(idPage, StatsData.class);
	}

	@Override
	public Page<StatsData> getStatsDataPageListOnToday(Map<String, Object> params) {
		Page<Long> idPage = this.getPage(params);
		idPage.setRecords(statsDataMapper.selectIdsByKeywordOnToday(idPage, params));
		return getPageNotFromRedis(idPage, StatsData.class);
	}

	@Override
	public Page<StatsData> getStatsDataPageListFromHistory(Map<String, Object> params) {
		Page<Long> idPage = this.getPage(params);
		idPage.setRecords(statsDataMapper.selectIdsByKeywordFromHistory(idPage, params));
		return getPageNotFromRedis(idPage, StatsData.class);
	}

	@Override
	public Page<StatsData> getStatsDataPageListForSummary(Map<String, Object> params) {
		Page<Long> idPage = this.getPage(params);
		idPage.setRecords(statsDataMapper.selectIdsByKeywordForSummary(idPage, params));
		return getPageNotFromRedis(idPage, StatsData.class);
	}

}
